# -*- coding: utf-8 -*-
# @File : playwrightStudy_实战2.py
# @Time : 2024/5/16 17:09
# @Author : syq
# @Email : 1721169065@qq.com
# @Software: PyCharm
'''
知识点：悬停登录
1.悬停到快捷导航（selenium是鼠标操作）
2.点击登录
3.在弹出的输入框中输入用户名/密码，点击登录
'''
from playwright.sync_api import sync_playwright
with sync_playwright() as ps:
    browser=ps.chromium.launch(headless=False)
    page=browser.new_page()
    #1.打开论坛
    page.goto('http://106.14.1.150:8090/forum.php')
    #2.悬停到快捷导航 hover()
    page.locator('#qmenu').hover()
    #3.点击弹出框中的登录按钮
    page.click('.xi2>strong')
    #4.在一个动态id的输入框中输入信息
    page.locator('[id^=username_L]').fill('admin') #这里的^是以什么开头（这里就是以username_L开头的id）
    page.wait_for_timeout(5000) #为了看效果
    page.locator('[id^=password3_L]').fill('123456')
    page.wait_for_timeout(5000)
    page.click('[name=loginsubmit].pn.pnc')  #点击登录按钮
    page.wait_for_timeout(5000)
